#!/sbin/runscript  

USER="nginx"
GROUP="nginx"
INTERPRETER="/usr/bin/python"
PORT="8888"

HOME="/home/${USER}" # Edit to your own username  
PYTHON="/var/calculate/www"
  
PROJECT_NAME="dj"  
PROJECT_DIR="$PYTHON/$PROJECT_NAME"  
PID_FILE="/var/run/dj/$PROJECT_NAME.pid"  
SOCKET_FILE="/tmp/$PROJECT_NAME.socket"  
MANAGE_FILE="$PROJECT_DIR/manage.py"  
METHOD="prefork"  

depend() {
    need mysql
}

start() {  
    # Starts the Django process  
    ebegin "Starting Django project $PROJECT_NAME" 
    start-stop-daemon --start --user $USER --group $GROUP \
	--verbose --exec ${INTERPRETER} ${MANAGE_FILE} \
	runfcgi maxchildren=10 maxspare=2 minspare=1 method=${METHOD} socket=$SOCKET_FILE pidfile=${PID_FILE} errlog=/var/log/dj/dj_error.log
    eend $? "Failed to start"
}

stop () { 
    # stops the daemon by cat'ing the pidfile  
    ebegin "Stopping Django project $PROJECT_NAME"  
    start-stop-daemon --stop --verbose --pidfile $PID_FILE
    eend $? "Failed to stop"
  
}

restart() {  
    ## Stop the service regardless of whether it was  
    ## running or not, start it again.    
    stop  
    start  
  
}


